home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* calllog.c */
- /* handles call log of Citadel-86 */
- /************************************************************************/
-
- #include "ctdl.h"
-
- /************************************************************************/
- /* history */
- /* */
- /* 86Jan22 HAW Set extern var so entire system knows baud. */
- /* 85Dec08 HAW Put blank lines in file. */
- /* 85Nov?? HAW Created. */
- /************************************************************************/
-
- /************************************************************************/
- /* Contents */
- /* */
- /* logMessage() Put out str to file. */
- /************************************************************************/
-
- extern struct config cfg;
- extern int byteRate;
-
- /************************************************************************/
- /* logMessage() Puts message out. Also, on date change, and */
- /* first output of system, insert blank line */
- /************************************************************************/
- logMessage(val, str)
- char *str;
- char val;
- {
- struct timeData {
- int y, d, h, m;
- char *month;
- label person;
- };
-
- static int oldDay = 0;
- static char *curBaud;
- static struct timeData lgin;
-
- int yr, dy, hr, mn;
- char *mon;
- label fn;
- FILE *fopen(), *fd;
-
- if (val == BAUD) {
- if (strCmp(str, "300" ) == SAMESTRING) byteRate = 30 ;
- else if (strCmp(str, "1200") == SAMESTRING) byteRate = 120;
- else if (strCmp(str, "2400") == SAMESTRING) byteRate = 240;
- else byteRate = 0 ;
- }
-
- if (cfg.call_log >= 100) return;
-
- getDate(&yr, &mon, &dy, &hr, &mn);
- switch (val) {
- case BAUD: curBaud = str;
- lgin.person[0] = 0;
- break;
- case L_IN: lgin.y = yr;
- lgin.d = dy;
- lgin.h = hr;
- lgin.m = mn;
- strCpy(lgin.person, str);
- lgin.month = mon; break;
- case CARRLOSS:
- case L_OUT:
- if (!lgin.person[0]) {
- curBaud = NULL;
- break;
- }
- sPrintf(fn, "%c:calllog.sys", cfg.call_log + 'a');
- if ((fd = fopen(fn, "a+")) == NULL)
- crashout("Call log error!");
-
- if (oldDay != dy)
- fprintf(fd, "\n");
-
- fprintf(fd, "%-22s: %2d%s%02d %2d:%02d - %2d:%02d (%s)\n",
- lgin.person, lgin.y, lgin.month, lgin.d, lgin.h, lgin.m,
- hr, mn, (curBaud == NULL) ? "sysConsole" : curBaud);
-
- fclose(fd);
-
- lgin.person[0] = 0;
-
- oldDay = dy;
- if (val == CARRLOSS) curBaud = NULL;
- break;
- default: printf("crashout: unknown case in switch statement");
- }
- }
-